import { defineConfig } from "vite"
import reactRefresh from "@vitejs/plugin-react-refresh"
// @ts-ignore
import { resolve } from "path"
import { viteMockServe } from "vite-plugin-mock"

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      // @ts-ignore
      "@": resolve(__dirname, "src"),
      // @ts-ignore
      Utils: resolve(__dirname, "src/utils"),
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
  build: {
    rollupOptions: {
      input: {
        index: resolve(__dirname, "index.html"),
        pegasus_login: resolve(__dirname, "pegasus_login/index.html"),
      },
    },
  },
  plugins: [
    reactRefresh(),
    viteMockServe({ mockPath: "mock", localEnabled: true, watchFiles: true }),
  ],
  server: {
    proxy: {
      "/pegasus/api/": {
        target: "http://120.77.223.43:6789",
        secure: false,
        changeOrigin: true,
      },
    },
  },
})
